#include "vector.h"
#include "misc.h"
ParticleVector::ParticleVector()
{
    dim = 3;
    d = new double[dim];
    for(int i = 0; i<dim; ++i)
        d[i]=0;
}

ParticleVector::ParticleVector(double x,double y,double z,int dim)
{
    this->dim = dim;
    d = new double[dim];
    d[0]=x;
    d[1]=y;
    d[2]=z;
}

ParticleVector::~ParticleVector()
{
    delete d;//deallocate the memory
}

ParticleVector* ParticleVector:: operator+(ParticleVector *op)
{

    return this->operator +(op->getCoords());
}
ParticleVector* ParticleVector::operator+(double *op)
{
    for(int i = 0; i<dim;++i)
        d[i] += op[i];
    return this;
}

ParticleVector* ParticleVector::operator*(ParticleVector *op)
{
    return this->operator *(op->getCoords());
}

ParticleVector* ParticleVector::operator*(double *op)
{
    for(int i = 0; i<dim; ++i)
        d[i]*=op[i];
    return this;
}

ParticleVector* ParticleVector::operator*(double op)
{
    for(int i = 0; i<dim; ++i)
        d[i]*=op;
    return this;
}

ParticleVector* ParticleVector::scalarMul(double t)
{
    ParticleVector *d2 = new ParticleVector();
    double *coord2 = d2->getCoords();
    for(int i = 0; i< dim; ++i)
        coord2[i]= d[i]*t;
    return this;
}

void ParticleVector::vecMul(ParticleVector* vec)
{

}

void ParticleVector::addVector(ParticleVector *vec)
{
    double *d2 = vec->getCoords();
    for(int i = 0; i<dim; ++i)
    {
        d[i]+=d2[i];
    }
}
